package ex4.multiThread;

import java.util.concurrent.Callable;

class MyThread4 implements Callable<String> {// 多线程主体类
	private int ticket = 10; // 卖票

	@Override
	public String call() throws Exception {
		for (int x = 0; x < 100; x++) {
			if (this.ticket > 0) {// 还有票可以出售
				System.out.println("卖票，ticket = " + this.ticket--);
			}
		}
		return "票已卖光！"; // 返回结果
	}
}

public class TestDemo4 {
	public static void main(String[] args) throws Exception {
		MyThread4 mt=new MyThread4();
		System.out.println(mt.call());
	}
}
